﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public enum eProductType
{
    None = 0,
    SnackAFactory = 1,
    SnackBFactory = 2,
    SnackCFactory = 3,
        
}

public class SnackFactoryMgr  : BaseLazySingleton<SnackFactoryMgr>
{
    Dictionary<eProductType, IProductFactory> productFactoryDic = new Dictionary<eProductType, IProductFactory>();
    
    
    public IProductFactory GetFactory(eProductType productType)
    {
        if (!productFactoryDic.ContainsKey(productType))
        {
            IProductFactory productFactory = null;
            switch (productType)
            {
                case eProductType.SnackAFactory:
                    productFactory = new SnackAFactory();
                    break;
                case eProductType.SnackBFactory:
                    productFactory = new SnackBFactory();
                    break;
                case eProductType.SnackCFactory:
                    productFactory = new SnackCFactory();
                    break;
               default:
                   break;
            }
            
            productFactoryDic.Add(productType, productFactory);
        }

        return productFactoryDic[productType];
    }
    
}


public interface IProductFactory
{
    Snack GetProduct();
}

// 产品A工厂 正经辣条工厂
public class SnackAFactory : SnackFactoryBase , IProductFactory
{
    // 负责有包装的辣味土豆
    public SnackAFactory()
    {
        SetRawMaterialFactory(new PotatoFactory());
        SetSeasoningFactory(new PepperFactory());
        SetPackingFactoryFactory(new PaperPackagingFactory());
    }
    
    public Snack GetProduct()
    {
        return CreateSnack("正经辣条");
    }
    
}

// 产品B工厂 科技与狠活
public class SnackBFactory : SnackFactoryBase , IProductFactory
{
    // 甜味的素肉
    public SnackBFactory()
    {
        SetRawMaterialFactory(new WheatFactory());
        SetSeasoningFactory(new SugarFactory());
        SetPackingFactoryFactory(new PlasticPackagingFactory());
    }

    protected override void SeasoningProgress(Snack snack)
    {
        base.SeasoningProgress(snack);
        snack.AddDescription("科技调味");
    }

    protected override void PackingProgress(Snack snack)
    {
        base.PackingProgress(snack);
        snack.AddDescription("狠活儿包装");
    }

    public Snack GetProduct()
    {
        return CreateSnack("科技狠活零食");
    }
}

// 产品C工厂 路边手作小摊
public class SnackCFactory : SnackFactoryBase , IProductFactory
{
    // 只会生产没有包装的面筋

    public SnackCFactory()
    {
        SetRawMaterialFactory(new WheatFactory());
        SetSeasoningFactory(new SugarFactory());
    }

    protected override void PackingProgress(Snack snack)
    {
        snack.AddDescription("没有包装");
    }


    public Snack GetProduct()
    {
       return CreateSnack("路边手作小面筋");
    }
}